package com.biaobiaoqi.scoreanalysis.administrator.action;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.biaobiaoqi.scoreanalysis.exception.DuplicateClazzTypeException;
import com.biaobiaoqi.scoreanalysis.service.IClazzTypeService;
import com.opensymphony.xwork2.ActionSupport;

public class AddClazzType extends ActionSupport {
 	private static final Log log=LogFactory.getLog(AddClazzType.class);
	private static final long serialVersionUID = 6422050253302804461L;
 	private String type;
 	@Resource
 	IClazzTypeService clazzTypeService;
 	public String execute() {
 		log.debug("type:"+type);
 		try {
			clazzTypeService.addClazzType(type);
			return SUCCESS;
		} catch (DuplicateClazzTypeException e) {
			addActionError("班级类型已存在");
			return INPUT;
		} catch (Exception e) {
			addActionError("服务器内部错误");
			System.out.println(e.getMessage());
			return ERROR;
		}
 	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}
